<?php
	$form	= $this->form;
	$form->prepare();
	$form->setAttribute('action', $this->url('admin', array('action' => 'addquestion')));

	$labelSubject	= $this->formLabel($form->get('subject'));
	$subject	= $this->formSelect($form->get('subject'));

	$labelType	= $this->formLabel($form->get('question_type'));
	$type	= $this->formSelect($form->get('question_type'));

	$labelQuestion	= $this->formLabel($form->get('content'));
	$question	= $this->formTextarea($form->get('content'));
	$errorQuestion	= $this->formElementErrors($form->get('content'));

	$labelChoice1	= $this->formLabel($form->get('choice_1'));
	$choice1	= $this->formTextarea($form->get('choice_1'));

	$labelChoice2	= $this->formLabel($form->get('choice_2'));
	$choice2	= $this->formTextarea($form->get('choice_2'));

	$labelChoice3	= $this->formLabel($form->get('choice_3'));
	$choice3	= $this->formTextarea($form->get('choice_3'));

	$labelChoice4	= $this->formLabel($form->get('choice_4'));
	$choice4	= $this->formTextarea($form->get('choice_4'));

// 	$labelAnswer1	= $this->formLabel($form->get('answer1'));
	$answer1	= $this->formRadio($form->get('answer1'));

// 	$labelAnswer2	= $this->formLabel($form->get('answer2'));
	$answer2	= $this->formMultiCheckbox($form->get('answer2'));

// 	$labelAnswer3	= $this->formLabel($form->get('answer3'));
	$answer3	= $this->formRadio($form->get('answer3'));

	$submit 	= $this->formInput($form->get('submit'));

	echo $this->form()->openTag($this->form);
?>
	<h2 class="sub-header" style="font-weight: bold;">Tạo câu hỏi</h2>
	<div class="form-group">
		<h4><?php echo $labelSubject; ?></h4>
		<?php echo $subject; ?>
	</div>
	<div class="form-group">
		<h4><?php echo $labelType; ?></h4>
		<?php echo $type; ?>
	</div>
	<div class="form-group">
		<h4><?php echo $labelQuestion; ?></h4>
		<div class="text-danger"><?php echo $errorQuestion; ?></div>
		<?php echo $question; ?>
	</div>
	<div class="form-group" id="type2-3a">
		<h4><?php echo $labelChoice1; ?></h4>
		<div class="text-danger"><?php if ($this->err[0] == 1) echo "<ul><li>Bạn phải nhập phương án trả lời</li></ul>"; ?></div>
		<?php echo $choice1; ?>
	</div>
	<div class="form-group" id="type2-3b">
		<h4><?php echo $labelChoice2; ?></h4>
		<div class="text-danger"><?php if ($this->err[1] == 1) echo "<ul><li>Bạn phải nhập phương án trả lời</li></ul>"; ?></div>
		<?php echo $choice2; ?>
	</div>
	<div class="form-group" id="type2-3c">
		<h4><?php echo $labelChoice3; ?></h4>
		<div class="text-danger"><?php if ($this->err[2] == 1) echo "<ul><li>Bạn phải nhập phương án trả lời</li></ul>"; ?></div>
		<?php echo $choice3; ?>
	</div>
	<div class="form-group" id="type2-3d">
		<h4><?php echo $labelChoice4; ?></h4>
		<div class="text-danger"><?php if ($this->err[3] == 1) echo "<ul><li>Bạn phải nhập phương án trả lời</li></ul>"; ?></div>
		<?php echo $choice4; ?>
	</div>
	<div class="form-group" id="type1">
		<h4 style="font-weight: bold;">Đáp án</h4>
		<p id="ans"><?php echo $answer1; ?></p>
	</div>
	<div class="form-group" id="type2">
		<h4 style="font-weight: bold;">Đáp án</h4>
		<p id="ans"><?php echo $answer2; ?></p>
	</div>
	<div class="form-group" id="type3">
		<h4 style="font-weight: bold;">Đáp án</h4>
		<p id="ans"><?php echo $answer3; ?></p>
	</div>
	<?php echo $this->formHidden($form->get('csrf'));?>
	<br>
	<p align="center"><?php echo $submit?></p>
<?php
	echo $this->form()->openTag($this->form);
?>

<script type="text/javascript">
	$(document).ready(function() {
		$.viewForm = {
			'1' : $('#type1'),
			'2' : $('#type2-3a, #type2-3b, #type2-3c, #type2-3d, #type2'),
			'3' : $('#type2-3a, #type2-3b, #type2-3c, #type2-3d, #type3')
		};

		$('#typeId').change(function() {
			// hide all
			$.each($.viewForm, function() { this.hide(); });
			// show current
			$.viewForm[$(this).val()].show();
		}).change();
	});
</script>